package org.luckystrophe.snowtoms;

import org.luckystrophe.snowtoms.adapter.AdapterSettings;

import android.content.Intent;
import android.view.KeyEvent;
import android.widget.ExpandableListView;

import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.facebook.Session;
import com.googlecode.androidannotations.annotations.AfterViews;
import com.googlecode.androidannotations.annotations.Bean;
import com.googlecode.androidannotations.annotations.EActivity;
import com.googlecode.androidannotations.annotations.ViewById;

@EActivity(R.layout.activity_setting)
public class SettingActivity extends SherlockFragmentActivity {

	@ViewById(R.id.lv_settinglist)
	ExpandableListView lv_settingList;

	@Bean
	AdapterSettings adapter;

	@AfterViews
	void afterViews() {
		lv_settingList.setAdapter(adapter);
		lv_settingList.expandGroup(0);
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			finishActivity();
		}
		return super.onKeyDown(keyCode, event);
	}

	private void finishActivity() {
		finish();
		overridePendingTransition(R.anim.leftin, R.anim.rightout);
	}

	@Override
	public void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
	}
}
